package com.second.lease.controller;

import com.second.common.pojo.R;
import com.second.lease.pojo.entity.CarShop;
import com.second.lease.pojo.vo.CarShopVO;
import com.second.lease.service.CarShopService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@Api
@RequestMapping("/carshop")
public class CarShopController {
    @Resource
    private CarShopService carShopService;

    @ApiOperation("查询全部商店")
    @RequestMapping("/select")
    public R selectCarShop(CarShopVO vo){
        return carShopService.selectCarShop(vo);
    }

    @ApiOperation("修改商店")
    @RequestMapping("/update")
    public R updateCarShop(@RequestBody CarShop vo){
        return carShopService.updateCarShop(vo);
    }

    @ApiOperation("新增商店")
    @RequestMapping("/insert")
    public R insertCarShop(@RequestBody CarShop vo){
        return carShopService.insertCarShop(vo);
    }

    @ApiOperation("删除商店")
    @RequestMapping("/delete")
    public R deleteCarShop( Integer id){
        return carShopService.deleteCarShop(id);
    }

    @ApiOperation("根据地区码查询对应的门店")
    @RequestMapping("/showCarShopByAreaId")
    public R showCarShopByAreaId(String areaId) {

        return carShopService.showCarShopByAreaId(areaId);
    }

    @ApiOperation("根据门店id查询对应的门店")
    @RequestMapping("/queryAddressById")
    public R queryAddressById(Integer id) {

        return carShopService.queryAddressById(id);
    }
}
